<?php
/**
* Display the list of uploaded files
*
* @author       Fabrice Douteaud <clearbudget@douteaud.com>
* @package      snippets
* @access       public
*/

/***********************************************************************

  Copyright (C) 2008  Fabrice douteaud (clearbudget@douteaud.com)

    This file is part of ClearBudget.

    ClearBudget is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClearBudget is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ClearBudget.  If not, see <http://www.gnu.org/licenses/>.


************************************************************************/
//prevent direct access
if(!defined('ENGINEON')) die('Direct access forbidden');
echo '<table class="tableReport" style="width:98%">';
$currencySymbol = class_propertyKey::getCurrencySymbol();
while(($transaction = $db->fetchRow()) != false) {
  // add the +/- sign on the transaction
  if($transaction['debit']) $transaction['amount'] = '-'.$transaction['amount'];
  else $transaction['amount'] = '+'.$transaction['amount'];
  // add the currency tag
  $transaction['amount'] = $currencySymbol.$transaction['amount'];
  // switch between deleted and not deleted transactions
  if($transaction['deleteFlag'] == "1") {
    $class = 'class="deletedRow"';
    $buttonImg = 'style/icons/arrow_undo.png';
    }
  else {
    $class = '';
    $buttonImg = 'style/icons/bin_empty.png';
    }
  // build the row
  echo "<tr {$class} id=\"transaction-{$transaction['id']}\">";
  echo '<td style="width:100px" >'.$transaction['operationDate'].'&nbsp;</td>';
  echo '<td style="width:80px">'.$transaction['amount'].'&nbsp;</td>';
  echo '<td style="width:400px">'.$transaction['payee'].'&nbsp;</td>';
  echo '<td style="width:200px">'.$transaction['memo'].'&nbsp;</td>';
  if($listOnly != 'true') {
    echo "<td style=\"width:20px\"><a href=\"#\" deleteTransaction=\"true\" id=\"{$transaction['id']}\"><img id=\"buttonImg-{$transaction['id']}\" src=\"{$buttonImg}\"/></a></td>";
    }
  echo '</tr>';
  }
echo '</table>';
?>